﻿// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable
using System;
using System.ComponentModel.DataAnnotations;

namespace WpfApp1.Models
{
    /// <summary>
    /// Модель, описывающая истории цен.
    /// </summary>
    public partial class PriceHistory : ICopied<PriceHistory>
    {
        public int Id { get; set; }
        public int ProductId { get; set; }
        public double Price { get; set; }

        private DateTime? _priceDate { get; set; }
        public DateTime PriceDate
        {
            get 
            { 
                return _priceDate ?? DateTime.Now; 
            }
            set
            {
                _priceDate = value;
            }
        }

        public virtual Products Product { get; set; } = null!;

        public PriceHistory Clone()
        {
            PriceHistory priceHistory = new PriceHistory();
            priceHistory.Id = Id;
            priceHistory.ProductId = ProductId;
            priceHistory.Price = Price;
            priceHistory.PriceDate = PriceDate;
            priceHistory.Product = Product;
            return priceHistory;
        }

        public void Copy(PriceHistory priceHistory)
        {
            Id = priceHistory.Id;
            ProductId = priceHistory.ProductId;
            Price = priceHistory.Price;
            PriceDate = priceHistory.PriceDate;
            Product = priceHistory.Product;
        }
    }
}